package com.zou.mall.member.controller;

import java.util.Arrays;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import com.zou.common.annotation.TokenCheck;
import com.zou.mall.member.feign.CouponFeignService;
import com.zou.mall.member.vo.LoginVO;
import com.zou.mall.member.vo.MemberSearchVO;
import com.zou.mall.member.vo.RegisterVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

import com.zou.mall.member.entity.MemberEntity;
import com.zou.mall.member.service.MemberService;
import com.zou.common.utils.PageUtils;
import com.zou.common.utils.R;

import javax.validation.Valid;


@Api("会员模块")
@RefreshScope
@RestController
@RequestMapping("member/member")
public class MemberController {

    @Autowired
    private MemberService memberService;


    @TokenCheck(check = false)
    @ApiOperation(value = "注册会员", notes = "注册会员")
    @PostMapping("/register")
    public R register(@RequestBody @Valid RegisterVO registerVO) {
        return memberService.register(registerVO);
    }

    @TokenCheck(check = false)
    @ApiOperation(value = "登录", notes = "登录")
    @PostMapping("/login")
    public R login(@RequestBody @Valid LoginVO loginVO) {
        return memberService.login(loginVO);
    }

    @GetMapping("/login-out")
    @ApiOperation(value = "登出", notes = "登出")
    public R loginOut(){
        return memberService.loginOut();
    }

    @TokenCheck(check = true)
    @PostMapping("/list")
    @ApiOperation(value = "分页查询", notes = "分页查询")
    public R queryList(@RequestBody MemberSearchVO memberSearchVO){
        return memberService.queryList(memberSearchVO);
    }
    @TokenCheck(check = true)
    @PostMapping("/v2/list")
    @ApiOperation(value = "分页查询2", notes = "分页查询2")
    public R list222(@RequestParam Map<String, Object> params) {
        PageUtils page = memberService.queryPage(params);
        return R.ok().put("page", page);
    }
}
